package com.smallstep.hystrix.client;

import com.smallstep.hystrix.handler.RestApiErrorHandler;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.web.client.HttpMessageConverterExtractor;
import org.springframework.web.client.ResponseExtractor;
import org.springframework.web.client.RestTemplate;

import java.lang.reflect.Type;

/**
 * @author 李俊
 */
public class FFRestTemplate extends RestTemplate {

    public FFRestTemplate(ClientHttpRequestFactory requestFactory) {
        super(requestFactory);
        this.setErrorHandler(new RestApiErrorHandler());
    }

    protected <T> ResponseExtractor<T> httpMessageConverterExtractor(Type responseType) {
        return new HttpMessageConverterExtractor(responseType, this.getMessageConverters());
    }
}
